package com.hsgene.common.exception;

import com.hsgene.common.util.exception.ErrorCode;

/**
 * @description:
 * @projectName: hdas-geneshop-server
 * @package: com.hsgene.common.exception
 * @author: maodi
 * @createDate: 2018/10/15 11:35
 * @version: 1.0
 * Copyright: Copyright (c) 2018
 */
public enum CommonErrorCode implements ErrorCode {

    USER_ID_IS_NULL(11000, "USER_ID_IS_NULL", "用户id为空"),
    USER_INFO_IS_NULL(11001, "USER_INFO_IS_NULL", "用户信息为空"),
    PAGE_IS_NULL(11002, "PAGE_IS_NULL", "页数为空"),
    PAGE_IS_NOT_POSITIVE_INTEGER(11003, "PAGE_IS_NOT_POSITIVE_INTEGER", "页数不是正整数"),
    SIZE_IS_NULL(11004, "SIZE_IS_NULL", "每页数量为空"),
    SIZE_IS_NOT_POSITIVE_INTEGER(11005, "SIZE_IS_NOT_POSITIVE_INTEGER", "每页数量不是正整数"),
    EMAIL_IS_NULL(11006, "EMAIL_IS_NULL", "邮箱为空"),
    EMAIL_IS_ERROR(11007, "EMAIL_IS_ERROR", "邮箱格式有误"),
    RANGE_TYPE_IS_NULL(11008, "RANGE_TYPE_IS_NULL", "范围类型为空"),
    RANGE_TYPE_IS_ERROR(11009, "RANGE_TYPE_IS_ERROR", "没有该范围类型"),
    SORT_ORDER_IS_ERROR(11010, "SORT_ORDER_IS_ERROR", "排序方式有误"),
    MOBILE_IS_NOT_NULL(11011, "MOBILE_IS_NOT_NULL", "移动电话不能为空"),
    MOBILE_IS_ERROR(11012, "MOBILE_IS_ERROR", "移动电话格式有误"),
    AGE_IS_NOT_NULL(11013, "AGE_IS_NOT_NULL", "年龄不能为空"),
    AGE_IS_ERROR(11014, "AGE_IS_ERROR", "年龄必须是正整数"),
    SEX_IS_NOT_NULL(11015, "SEX_IS_NOT_NULL", "性别不能为空"),
    SEX_IS_ERROR(11016, "SEX_IS_ERROR", "代表性别数字有误"),
    PLATFORM_IS_NOT_NULL(11017, "PLATFORM_IS_NOT_NULL", "平台参数不能为空"),
    PLATFORM_IS_ERROR(11018, "PLATFORM_IS_ERROR", "平台参数有误");

    private final int code;

    private final String message;

    private final String description;

    CommonErrorCode(int code, String message, String description) {
        this.code = code;
        this.message = message;
        this.description = description;
    }

    public static CommonErrorCode getEnum(int code) {
        for (CommonErrorCode errorCode : values()) {
            if (errorCode.code == code) {
                return errorCode;
            }
        }
        throw new IllegalArgumentException("No element matches " + code);
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getDescription() {
        return description;
    }

}
